#ifndef __GENERICCLIENT_H__
#define __GENERICCLIENT_H__

typedef struct GenClient_t GenClient;

typedef enum GClientProtocol_t
{
    GC_TCP  ,
    GC_UDP
}GClientProtocol;

typedef enum GCErr_t
{
    GC_SUCCESS = 0,
    GC_ERR_CONN_SHUTDOWN ,
    GC_ERR_SEND          ,
    GC_ERR_RECV
}GCErr;

/*  Create new generic client. get as parameters: connetion ip, port, and protocol TCP\UDP. *
 *  The new function also create socket and connect on TCP protocol.                        *
 *  Return GenClient pointer on success, if fail return 0 and print to stderr. Failure can  *
 *  occure on allocation fail or socket create or connect in tcp failed.                    */
GenClient* GenClientNew(char* _ip, int _port, GClientProtocol _protocol);

/*  Read to buffer the given size. This is a blocking action. Return 0 on success, on fail  *
 *  return error numbers (GCErr).                                                           */
int GenClientRead(GenClient* , void* _buffer, size_t _size);


/*  Write to server the given buffer. This is a blocking action. Return 0 on success, on    *
 *  fail return error numbers (GCErr).                                                      */
int GenClientWrite(GenClient* , void* _buffer, size_t _size);

/*  Delete client and close socket                                                          */
void GenClientDelete(GenClient* );


#endif /* __GENERICCLIENT_H__   */
